<?php


namespace App\HttpController;


use App\Utils\BaiduTts;
use EasySwoole\Http\AbstractInterface\Controller;

class Index extends Controller
{

    public function index()
    {
        $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/welcome.html';
        if(!is_file($file)) {
            $file = EASYSWOOLE_ROOT.'/src/Resource/Http/welcome.html';
        }
        $this->response()->write(file_get_contents($file));
    }

    protected function actionNotFound(?string $action)
    {
        $this->response()->withStatus(404);
        $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/404.html';
        if(!is_file($file)) {
            $file = EASYSWOOLE_ROOT.'/src/Resource/Http/404.html';
        }
        $this->response()->write(file_get_contents($file));
    }

    public function test()
    {
        $baiduTts = new BaiduTts();
//        $data = $baiduTts->getAccessToken('KoG0dqLkmfj5sL5r0nXDtUGa', '8DSCzqQZuq0Eb9BGafpuo5lyA6IvSeAT');
        $res = $baiduTts->getAudioFile('请五诊HAROON RASHEED到肌肉注射室进行输液');

    }
}